package face.pay.web.paycode.controller;

import face.pay.entity.MchPayCodeBatch;
import face.pay.entity.UserInfo;
import face.pay.security.annotation.CurrentUser;
import face.pay.util.ResultMessage;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import face.pay.web.paycode.service.IPayCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Controller
@RequestMapping("/mch_payCode")
public class PayController {

    @Autowired
    IPayCodeService iPayCodeService;

    @RequestMapping("/index")
    public String index(){

        return  "paycode/index";
    }


    @RequestMapping("/queryBatchData")
    @ResponseBody
    public PageData queryData(@CurrentUser UserInfo loginUser,  PageParam pageParam, MchPayCodeBatch mchPayCodeBatch){
        return  iPayCodeService.queryBatchCode(pageParam,loginUser,mchPayCodeBatch);
    }


    @RequestMapping("/addBatchCode")
    @ResponseBody
    public ResultMessage addBatchCode(@CurrentUser UserInfo loginUser, MchPayCodeBatch mchPayCodeBatch){
        return  iPayCodeService.addBatchCode(loginUser,mchPayCodeBatch);
    }

    @RequestMapping("/down")
    public void down(@CurrentUser UserInfo loginUser, Integer batchId, HttpServletRequest request, HttpServletResponse response){
          iPayCodeService.down(loginUser,batchId,request,response);
    }


}
